﻿using System;
using System.Data;
using System.Data.SQLite;

namespace ConsoleApplication1
{
    class Program
    {
         

        static void Main(string[] args)
        {

            //SQLite Database Interaction
            string dbPath = "C:/ProgramData/Team MediaPortal/MediaPortal/database";
            string dbName = "TVSeriesDatabase4.db3";
            SQLiteConnection DB_MPTV_Connection;
            SQLiteCommand DB_Command;
            SQLiteDataAdapter DB_Adapter;
            DataSet DS = new DataSet();  

            Console.WriteLine("Starting...");

            //Connect To DB
            DB_Connect();

            //Execute Query
            DataTable DB_Resutls = DB_executeQuery(DB_MPTV_Connection, "SELECT Pretty_Name FROM Online_Series WHERE ID='72173'");

            string queryStingResult = DB_Resutls.Rows[0].ItemArray[0].ToString();
        }

        static void DB_Connect()
        {
            DB_MPTV_Connection = new SQLiteConnection("Data Source=C:/ProgramData/Team MediaPortal/MediaPortal/database/TVSeriesDatabase4.db3;Version=4;New=False;Compress=True");
        }

        static DataTable DB_executeQuery(SQLiteConnection dbConnection, string queryString)
        {
            DB_Connect();
            dbConnection.Open();
            DB_Command = dbConnection.CreateCommand();
            DB_Adapter = new SQLiteDataAdapter(queryString, dbConnection);
            DS.Reset();
            DB_Adapter.Fill(DS);
            DataTable results = DS.Tables[0];
            dbConnection.Close();
            return results;
        }

        
    }
}
